package com.example.cofeed.adapter;

import android.content.Intent;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.cofeed.R;
import com.example.cofeed.activity.DemandIssueActivity;
import com.example.cofeed.constant.IntentKeyConstant;
import com.example.cofeed.entity.Supply;

public class SupplyDemandAdapter extends BaseQuickAdapter<Supply, BaseViewHolder> {
    public SupplyDemandAdapter() {
        super(R.layout.adapter_supply_demand);
    }

    @Override
    protected void convert(BaseViewHolder helper, Supply item) {

        helper.itemView.findViewById(R.id.layout).setOnClickListener(v -> {
            Intent intent = new Intent(mContext, DemandIssueActivity.class);
            intent.putExtra(IntentKeyConstant.DEMAND_ID, item.id);
            mContext.startActivity(intent);
        });
        helper.setText(R.id.tv_name, item.title);
        helper.setText(R.id.tv_date, item.addtime);

        helper.addOnClickListener(R.id.ll_change);
        helper.addOnClickListener(R.id.ll_refresh);

        if (item.curstate == 1) {
            helper.setText(R.id.tv_status, "正常");
            helper.setBackgroundColor(R.id.tv_status, mContext.getResources().getColor(R.color.colorAccent));
        } else {
            helper.setText(R.id.tv_status, "待审核");
            helper.setBackgroundColor(R.id.tv_status, mContext.getResources().getColor(R.color.colorOrange));

        }

    }
}
